package com.zhangck.bos_fore.action; 
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

/** 
* @author 上午茶
* @version 创建时间：2018年6月10日 上午10:10:41 
* 类说明 
*/
import cn.itcast.crm.domain.Customer;
@ParentPackage("json-default")
@Namespace("/")
@Controller
@Scope("prototype")
public class UserLoginAction  extends BaseAction<Customer>{

	@Action(value="userlogin_action" ,results={@Result(name="success", type="redirect", location="index.html#/myhome"),
			@Result(name="login", type="redirect", location="login.html")})
	public String userlogin_action(){
		
		 Customer customer = WebClient.create("http://127.0.0.1:8088/services/customerService/Customer/loginCutomer?telephone=13212345678&password=123456").accept(MediaType.APPLICATION_JSON_TYPE).get(Customer.class);
		 if (customer==null) {
			 return "login";
		}
		 ServletActionContext.getRequest().getSession().setAttribute("loginCustomer", customer);
		 return "success";
	}
}
